package com.ebo.synframework.synroom.executor;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class SynRoom {
    private final AtomicBoolean isProcessing = new AtomicBoolean(false);
    
    private final AtomicInteger poolIndex = new AtomicInteger(-1);
    
    private final long roomId;
    
    public SynRoom(long roomId) {
        this.roomId = roomId;
    }
    
    public final boolean setProcessing(boolean isProcessing) {
    	return this.isProcessing.compareAndSet(!isProcessing, isProcessing);
    }
    
    public final boolean isProcessing() {
        return this.isProcessing.get();
    }

    public long getRoomId() {
        return roomId;
    }
    
    public boolean casPoolIndex(int poolIndex) {
        return this.poolIndex.compareAndSet(-1, poolIndex);
    }
    
    public int getPoolIndex() {
        return this.poolIndex.get();
    }
}
